﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace ProjetoFinal
{
    public class Leaf
    {
        // FAZER O RETÂNGULO DA FOLHA UM POUCO MAIS FINO QUE A ALTURA DA IMAGEM DELA, PARA PARECER QUE ELE ESTÁ
        // BATENDO A BUNDINHA NA FOLHA *-*

        public Texture2D texture;
        int rateMove;
        public Rectangle rect;
   
        public Leaf(int rateMove, Rectangle rect)
        {
            this.rateMove = rateMove;
            this.rect = rect;
        }

        public void LoadContent(ContentManager content)
        {
            texture = content.Load<Texture2D>("leaf");
        }


        public void Move(KeyboardState nowKeybord, KeyboardState oldKeyboard)
        {
            if (!(rect.X >= 1024 - rect.Width))
            {
                if (nowKeybord.IsKeyDown(Keys.Right))
                {
                    rect.X += rateMove;

                }
            }

            if (rect.X != 0)
            {
                if (nowKeybord.IsKeyDown(Keys.Left))
                {
                    rect.X -= rateMove;
                }
            }

        }


        public void BackToPosition(ref bool lostLife)
        {
            if (lostLife)
            {
                rect.X = 360;
                rect.Y = 677;
                lostLife = false;
            }
        }


        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, rect, Color.White);
        }
    }
}
